package com.itgaoshu.hospitalproject.mapper;

import com.itgaoshu.hospitalproject.bean.DataGridView;
import com.itgaoshu.hospitalproject.bean.Role;
import com.itgaoshu.hospitalproject.bean.RoleMenu;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface RoleMapper {
    //查找所有角色
    List<Role> selectAllRole(Role role);

    //添加角色
    @Insert("insert into sys_role(rolename,roledesc,available)values(#{rolename},#{roledesc},#{available})")
    int insertRole(Role role);

    //修改角色信息
    @Update("update sys_role set rolename=#{rolename},roledesc=#{roledesc},available=#{available} where roleid=#{roleid}")
    int updateRole(Role role);

    //删除角色
    @Delete("delete from sys_role where roleid=#{roleid}")
    int deleteRoleId(Integer roleid);

    //删除角色与菜单的关系
    @Delete("delete from sys_role_menu where rid=#{roleid}")
    int deleteRoleMenuId(Integer roleid);

    //删除角色与用户的管理
    @Delete("delete from sys_role_user where rid=#{roleid}")
    int deleteRoleUserId(Integer roleid);

    //初始角色菜单
    //DataGridView initRoleMenuTreeJson(int roleid);

    //保存角色与菜单的关系
    //void saveRoleMenu(RoleMenu roleMenu);

    //添加角色
    @Insert("insert into sys_role_menu(rid,mid)values(#{rid},#{mid});")
    void insertRoleMenu(@Param("rid")Integer rid, @Param("mid")Integer mid);
}
